<?php
/**
 * Emulates an object with get/set based on the key/values of an array.
 */
class ArrayTransformer {
    private $array;
    
    public function __construct(array $array) {
        $this->array = &$array;
    }
    
    public function __call($function, $arguments) {
        if (preg_match('#get([A-Z][\w\d]*)#', $function, $match)) {
            return array_get($this->array, lcfirst($match[1]), null);
        }
        else {
            throw new RuntimeException("No such method: $function");
        }
    }
}
